#ifndef    _DEFINE_H
#define    _DEFINE_H
#include<stdio.h>

//declare
typedef  bit   Bit;
typedef  bit   Bool;
typedef  unsigned char Byte;
typedef  unsigned int  Word;
typedef  unsigned long Long;

#define  DATA  data
#define  IDATA idata

#define  PDATA pdata
#define  XDATA xdata
#define  RDATA code

#define  HIBYTE_REF(addr)    (* ((Byte *) & addr))
#define  LOBYTE_REF(addr)    (* ((Byte *) & addr+1))
#define  MAKEWORD(v1,v2)     ((((Word)(v1))<<8)+(Word)(v2))
#define  HIBYTE(v1)          ((Byte)((v1)>>8))
#define  LOBYTE(v1)          ((Byte)((v1)&0xff))

#define  TIME_BASE   40
#define  TIME_1MIN   (60000/TIME_BASE)
#define  TIME_25SEC  (25000/TIME_BASE)
#define  TIME_20SEC  (20000/TIME_BASE)
#define  TIME_15SEC  (15000/TIME_BASE)
#define  TIME_10SEC  (10000/TIME_BASE)
#define  TIME_8SEC   (8000/TIME_BASE)
#define  TIME_6SEC   (6000/TIME_BASE)
#define  TIME_5SEC   (5000/TIME_BASE)
#define  TIME_4SEC   (4000/TIME_BASE)
#define  TIME_3SEC   (3000/TIME_BASE)
#define  TIME_2SEC   (2000/TIME_BASE)
#define  TIME_1SEC   (1000/TIME_BASE)
#define  TIME_400MS  (400/TIME_BASE)
#define  TIME_80MS   (80/TIME_BASE)

#define  CLOCK_BASE      1
#define  CLOCK_40MS      (65536 - 40000 * CLOCK_BASE)
#define  CLOCK_4096us    (65536 - 4096 * CLOCK_BASE)
#define  CLOCK_5000us    (65536 - 5000 * CLOCK_BASE)
#define  CLOCK_10000us   (65536 - 10000 * CLOCK_BASE)

#define  SUCCESS   0
#define  FAILURE   1
#define  FALSE  (Bool)0
#define  TRUE   (Bool)!FALSE

//key
#define  NO_KEY    0
#define  KEY1      1
#define  KEY2      2
#define  KEY3      3
#define  KEY4      4
#define  KEY5      5
#define  KEY6      6
#define  KEY7      7
#define  KEY8      8
#define  KEY9      9
#define  KEY10    10
#define  KEY11    11
#define  KEY12    12
#define  DOUBLE_KEY  99

//eeprom
#define  VERSION_ID  0x55aa
#define  VERSION_ADR 1024-2   //eeprom last two bytes
#define  VARIABLE1_ADDRESS   0
#define  START_ADDRESS  80

//osd
#define  DEVICE_ADR    0x7a
#define  BLACK         0x00
#define  BLUE          0x01
#define  GREEN         0x02
#define  CYAN          0x03
#define  RED           0x04
#define  MAGENTA       0x05
#define  YELLOW        0x06
#define  WHITE         0x07
#define  BLINK         0x08
#define  ATTRIBUTE_ROW      0xa0
#define  ATTRIBUTE_COLUMN   0x40
#define  DISPLAY_ROW        0x80
#define  DISPLAY_COLUMN     0x40
#define  USERFONT_ROW       0xc0
#define  USERFONT_COLUMN    0X40

//osd font
#define  _SPACE      0x00
#define  _MINUS      0x20
#define  _PLUS       0x21
#define  _DOT        0xe6
#define  _COLON      0x3a
#define  _SLASH      0x5f
#define  _DITTO      0x13
#define  _COMMA      0x2b
#define  _HBarR      0x77
#define  _HBar0      0x76
#define  _HBar1      0x75
#define  _HBar2      0x74
#define  _HBar3      0x73
#define  _HBar4      0x72
#define  _HBar5      0x71
#define  _HBar6      0x70
#define  _HBarL      0x6f

#define  _EOF        0xFF
#define  _ESC        0xFE
#define  _1ST        0x01
#define  _2ND        0x02
#define  __          0x00
#define  _0          0x4f
#define  _1          0x31
#define  _2          0x32
#define  _3          0x33
#define  _4          0x34
#define  _5          0x35
#define  _6          0x36
#define  _7          0x37
#define  _8          0x38
#define  _9          0x39
#define  _A          0x41
#define  _B          0x42
#define  _C          0x43
#define  _D          0x44
#define  _E          0x45
#define  _F          0x46
#define  _G          0x47
#define  _H          0x48
#define  _I          0x49
#define  _J          0x4a
#define  _K          0x4b
#define  _L          0x4c
#define  _M          0x4d
#define  _N          0x4e
#define  _O          0x4f
#define  _P          0x50
#define  _Q          0x51
#define  _R          0x52
#define  _S          0x53
#define  _T          0x54
#define  _U          0x55
#define  _V          0x56
#define  _W          0x57
#define  _X          0x58
#define  _Y          0x59
#define  _Z          0x5a
#define  _a          0x08
#define  _b          0x09
#define  _c          0x0a
#define  _d          0x0b
#define  _e          0x0c
#define  _f          0x0d
#define  _g          0x0e
#define  _h          0x0f
#define  _i          0x10
#define  _j          0x24
#define  _k          0x25
#define  _l          0x3b
#define  _m          0x60
#define  _n          0x62
#define  _o          0x63
#define  _p          0x66
#define  _q          0x6b
#define  _r          0x7a
#define  _s          0x7b
#define  _t          0xa0
#define  _u          0xa1
#define  _v          0xb8
#define  _w          0xb9
#define  _x          0x01
#define  _y          0xc5
#define  _z          0x1a
//multi-language ID
#define  LANGUAGE_ENGLISH     0
#define  LANGUAGE_FRENCH      1
#define  LANGUAGE_GERMAN      2
#define  LANGUAGE_ITALY       3
#define  LANGUAGE_SPAINISH    4

#endif







